﻿using Modbus.Device;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace YmSoft.WPF.Modbus
{
    public class MVReadHoldingRegisters : MVMessageBase
    {
        public MVReadHoldingRegisters(MVModbus mvModbus) : base(mvModbus) { }


        ushort startAddress = 1;
        public ushort StartAddress
        {
            get
            {
                return this.startAddress;
            }

            set
            {
                if (value != this.startAddress)
                {
                    this.startAddress = value;
                    NotifyPropertyChanged("StartAddress");
                }
            }
        }

        ushort numberOfPoints = 1;
        public ushort NumberOfPoints
        {
            get
            {
                return this.numberOfPoints;
            }

            set
            {
                if (value != this.numberOfPoints)
                {
                    this.numberOfPoints = value;
                    NotifyPropertyChanged("NumberOfPoints");
                }
            }
        }
        protected override void SendMessage(IModbusSerialMaster master)
        {
            var result = master.ReadHoldingRegisters(SlaveAddress, StartAddress, NumberOfPoints);
        }
    }
}
